package java_zuoye_3;

import java.util.ArrayList;
import java.util.Scanner;

public class homework_3 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int num;
		int tempnum;
		int flag = 1;
		int flag1 = 0;
		num = sc.nextInt();
		for(int i = 0; i < num; i++) {
			tempnum = sc.nextInt();
			list.add(tempnum);
		}
		System.out.println(list);
		for(int i = 0;i < list.size() - 1; i++) {
			if(list.get(i) == list.get(i+1)) {
				flag++;
				if(flag == 4) {
					flag1 = 1; 
				}
				continue;
			}
			flag = 1;
		}
		if(flag1 == 1) {
			System.out.println("yes");
		}else {
			System.out.println("no");
		}
	}
}
